package com.jwds.digital.bios.business.core.infrastructure.dto.basic.assembler;

import com.jwds.digital.bios.business.core.infrastructure.dto.basic.BasicDictReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.dto.basic.BasicOperateLogReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.entity.basic.BasicDict;
import com.jwds.digital.bios.business.core.infrastructure.entity.basic.BasicOperateLog;
import com.jwds.digital.bios.business.core.infrastructure.vo.basic.BasicOperateLogRespVO;

import java.util.Objects;

/**
 * @Description BeltAnomalyInfoAssembler1
 * @Author xiao  xun
 * @Date 2024-12-09
 */
public class BasicDictAssembler {
    public static BasicDict dto2entity(BasicDictReqDTO dto)  {
        if (dto == null) {
            return null;
        }
        BasicDict entity = new BasicDict();
        entity.setItemCode(dto.getItemCode());
        entity.setItemName(dto.getItemName());
        entity.setItemValue(dto.getItemValue());
        entity.setParentCode(dto.getParentCode());
        entity.setSort(dto.getSort());
        entity.setRemark(dto.getRemark());
        return entity;
    }


    public static BasicDict dto2entity(BasicDictReqDTO dto, BasicDict entity){
        if (dto == null) {
            return null;
        }
        if(Objects.nonNull(dto.getItemCode())) {
            entity.setItemCode(dto.getItemCode());
        }
        if(Objects.nonNull(dto.getItemName())) {
            entity.setItemName(dto.getItemName());
        }
        if(Objects.nonNull(dto.getItemValue())) {
            entity.setItemValue(dto.getItemValue());
        }
        if(Objects.nonNull(dto.getParentCode())) {
            entity.setParentCode(dto.getParentCode());
        }
        if(Objects.nonNull(dto.getSort())) {
            entity.setSort(dto.getSort());
        }
        if(Objects.nonNull(dto.getRemark())) {
            entity.setRemark(dto.getRemark());
        }
        return entity;
    }

    public static BasicDictReqDTO entity2dto(BasicDict entity) {
        if (entity == null) {
            return null;
        }
        BasicDictReqDTO dto = new BasicDictReqDTO();
        dto.setId(entity.getId());
        dto.setItemCode(entity.getItemCode());
        dto.setItemName(entity.getItemName());
        dto.setItemValue(entity.getItemValue());
        dto.setParentCode(entity.getParentCode());
        dto.setSort(entity.getSort());
        dto.setRemark(entity.getRemark());
        return dto;
    }
}
